<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\CourseLabel
 *
 * @property int $id
 * @property int $course_id 课程id
 * @property string $name 标签名称
 * @property string|null $deleted_at
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseLabel newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseLabel newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseLabel query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseLabel whereCourseId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseLabel whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseLabel whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseLabel whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseLabel whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseLabel whereUpdatedAt($value)
 * @mixin \Eloquent
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Query\Builder|\App\CourseLabel onlyTrashed()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Query\Builder|\App\CourseLabel withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\CourseLabel withoutTrashed()
 */
class CourseLabel extends Model
{
    use SoftDeletes;

    public static function getCourseLabel($course_id){
        if(empty($course_id))
            return [];

        $courseLabelArr = [];
        $courseLabelList = self::whereCourseId($course_id)->get();
        if(count($courseLabelList) > 0){
            foreach ($courseLabelList as $courseLabel){
                array_push($courseLabelArr,$courseLabel->name);
            }
        }

        return $courseLabelArr;
    }
}
